<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="企业姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgName">
              <a-input v-model="model.orgName" placeholder="请输入企业姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统一信用代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="creditCode">
              <a-input v-model="model.creditCode" placeholder="请输入统一信用代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="法人姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="legalName">
              <a-input v-model="model.legalName" placeholder="请输入法人姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="电子邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="email">
              <a-input v-model="model.email" placeholder="请输入电子邮箱"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
              <a-input v-model="model.phone" placeholder="请输入联系电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="推荐单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recommendOrg">
              <a-input v-model="model.recommendOrg" placeholder="请输入推荐单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="注册类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registerType">
              <a-input v-model="model.registerType" placeholder="请输入注册类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="注册资本" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registerCapital">
              <a-input v-model="model.registerCapital" placeholder="请输入注册资本"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="注册时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="registerTime">
              <a-input v-model="model.registerTime" placeholder="请输入注册时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单位地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
              <a-input v-model="model.address" placeholder="请输入单位地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postalCode">
              <a-input v-model="model.postalCode" placeholder="请输入邮政编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="网址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="website">
              <a-input v-model="model.website" placeholder="请输入网址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单位性质" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgNature">
              <a-input v-model="model.orgNature" placeholder="请输入单位性质"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="传真" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fax">
              <a-input v-model="model.fax" placeholder="请输入传真"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否为高新企业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isHighTech">
              <a-input-number v-model="model.isHighTech" placeholder="请输入是否为高新企业" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="职工人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
              <a-input v-model="model.num" placeholder="请输入职工人数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="高新企业批文号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="highTechNo">
              <a-input v-model="model.highTechNo" placeholder="请输入高新企业批文号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="高新企业批文时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="highTechTime">
              <a-input v-model="model.highTechTime" placeholder="请输入高新企业批文时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="industry">
              <a-input v-model="model.industry" placeholder="请输入所属行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="龙头企业发证单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="keyEnterprisesOrgName">
              <a-input v-model="model.keyEnterprisesOrgName" placeholder="请输入龙头企业发证单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发证单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="keyEnterprisesTime">
              <a-input v-model="model.keyEnterprisesTime" placeholder="请输入发证单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="主管会计" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountingName">
              <a-input v-model="model.accountingName" placeholder="请输入主管会计"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="会计证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountingNo">
              <a-input v-model="model.accountingNo" placeholder="请输入会计证号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统计员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="statisticianName">
              <a-input v-model="model.statisticianName" placeholder="请输入统计员"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统计员证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="statisticianNo">
              <a-input v-model="model.statisticianNo" placeholder="请输入统计员证号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否有研究机构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isResearch">
              <a-input-number v-model="model.isResearch" placeholder="请输入是否有研究机构" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否有新产品开发中心" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isDevelopmentCentre">
              <a-input-number v-model="model.isDevelopmentCentre" placeholder="请输入是否有新产品开发中心" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="民营企业发证时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="privateEnterpriseTime">
              <a-input v-model="model.privateEnterpriseTime" placeholder="请输入民营企业发证时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="民营企业发证批文" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="privateEnterpriseNo">
              <a-input v-model="model.privateEnterpriseNo" placeholder="请输入民营企业发证批文"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="年销售额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sales">
              <a-input v-model="model.sales" placeholder="请输入年销售额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单位简介" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgDescribe">
              <a-textarea v-model="model.orgDescribe" rows="4" placeholder="请输入单位简介" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="删除标记" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">
              <a-input-number v-model="model.delFlag" placeholder="请输入删除标记" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="人员架构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="personnelInfo">
              <a-input v-model="model.personnelInfo" placeholder="请输入人员架构"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="装备情况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentInfo">
              <a-input v-model="model.equipmentInfo" placeholder="请输入装备情况"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="经营情况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessInfo">
              <a-input v-model="model.businessInfo" placeholder="请输入经营情况"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="产品情况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productInfo">
              <a-input v-model="model.productInfo" placeholder="请输入产品情况"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'UmsEnterpriseForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/umsEnterprise/umsEnterprise/add",
          edit: "/umsEnterprise/umsEnterprise/edit",
          queryById: "/umsEnterprise/umsEnterprise/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>